package com.zhao.service;

import com.zhao.dao.primary.UserDao;
import com.zhao.dao.secondary.EmployeeDao;
import com.zhao.entity.primary.User;
import com.zhao.entity.secondary.Employee;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * @Author:zhao
 * @Date: 2018/8/27 15:59
 * @Description:
 */
@Service
public class MultipleService {

    @Autowired
    private UserDao userDao;

    @Autowired
    private EmployeeDao employeeDao;

    @Transactional(rollbackFor = Exception.class)
    public void insert(User user, Employee employee, boolean th) throws Exception {
        userDao.insert(user);
        employeeDao.insert(employee);
        if (th) {
            throw new Exception("");
        }
    }

}
